import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class CodeGenerator352 {
    public static void main(String[] args) {
        String database = "study_springboot";
        String packageName = "cn.jdx";
        String [] tables = {"user","items","orders","orderdetail"}; //表名称
        String [] filtrateTableNamePrefix = {"t_", "c_"};
        String outputPath = "D://测试";


        String url = "jdbc:mysql://localhost:3306/"+database+"?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC";
        String username="root";
        String password="root";

        FastAutoGenerator.create(url, username, password)
                .globalConfig(builder -> {
                    builder.author("纪德雄") // 设置作者
//                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir(outputPath); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent(packageName) // 设置父包名
//                            .moduleName("system") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, outputPath)); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude(tables) // 设置需要生成的表名
                            .addTablePrefix(filtrateTableNamePrefix); // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用 Freemarker 引擎模板，默认的是 Velocity 引擎模板
                .execute();
        System.out.println("[执行完毕]");
    }
}
